package cn.edu.wfit.common.core.interceptor;/*
package cn.edu.wfit.common.core.interceptor;

import cn.edu.wfit.common.core.constant.HttpStatus;
import cn.edu.wfit.common.core.constant.TokenConstants;
import cn.edu.wfit.common.core.context.SecurityContextHolder;
import cn.edu.wfit.common.core.domain.R;
import cn.edu.wfit.common.core.utils.ServletUtils;
import cn.edu.wfit.common.core.utils.StringUtils;
import com.fasterxml.jackson.databind.ObjectMapper;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.http.HttpStatusCode;
import org.springframework.http.MediaType;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.HandlerInterceptor;

import java.io.PrintWriter;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;

public class AuthInterceptor implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        if(!(handler instanceof HandlerMethod)){
            return true;
         */
/*   R<Object> jsonResult = R.fail(HttpStatus.BAD_REQUEST, "非法请求!!");
            ObjectMapper mapper = new ObjectMapper();
            String jsonResponse = mapper.writeValueAsString(jsonResult);
            ServletUtils.renderString(response,jsonResponse);
            return false;*//*

        }

        String userId = request.getHeader(TokenConstants.USER_ID_HEADER);
        if (StringUtils.isNotBlank(userId)) {
         //  UserContext.setUserId(Long.parseLong(userId));
           SecurityContextHolder.setUserId(userId);
            */
/*R<Object> jsonResult = R.fail(HttpStatus.BAD_REQUEST, "没有接收到网关服务的用户信息");
            ObjectMapper mapper = new ObjectMapper();
            String jsonResponse = mapper.writeValueAsString(jsonResult);
            ServletUtils.renderString(response,jsonResponse);
            return false;*//*

        }

        return true;
    }

    @Override
    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
       // UserContext.removeUserId();
        SecurityContextHolder.remove();
    }
}
*/
